package org.cfg;

import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import org.apache.commons.lang3.ArrayUtils;
import java.util.HashMap;
import com.sojoys.artifact.tools.SK_String;
import com.xiaoleilu.hutool.util.StrUtil;
import com.sojoys.artifact.build.data.base.BaseCfg;
import java.util.List;
import com.google.common.collect.Lists;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.tools.ToolCopy;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.sojoys.artifact.constant.DataModelKeyEnum;
/**
 * 道具恢复次数
 */
public class ItemRecoverCfg extends BaseCfg<ItemRecoverCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "item_recover";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.ItemRecoverCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 7;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","道具ID","自动恢复时间间隔(秒)","恢复数量","最大恢复上限","购买价格 格式111:50:10|222:50:10&333:50:10-222:50:10&333:50:10","重置购买次数时间",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","item_id","cooldown","recover_count","maxRecoverCount","price","resetBuyCountTime",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","itemId","cooldown","recoverCount","maxRecoverCount","price","resetBuyCountTime",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,2116204999,-546109589,1231308404,589428111,106934601,-1095859323,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","int","int","int","int","String[]","int",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Integer.class,Integer.class,Integer.class,Integer.class,String[].class,Integer.class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 道具ID
	 */
	private int itemId;
	
	/**
	 * 自动恢复时间间隔(秒)
	 */
	private int cooldown;
	
	/**
	 * 恢复数量
	 */
	private int recoverCount;
	
	/**
	 * 最大恢复上限
	 */
	private int maxRecoverCount;
	
	/**
	 * 购买价格 格式111:50:10|222:50:10&333:50:10-222:50:10&333:50:10
	 */
	private String[] price;
	
	/**
	 * 重置购买次数时间
	 */
	private int resetBuyCountTime;
	
	
	
	public static ItemRecoverCfg builder() {
		ItemRecoverCfg itemRecoverCfg = new ItemRecoverCfg();
		return itemRecoverCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 道具ID
	 */
	public int getItemId() {
		return itemId;
	}
	
	/**
	 * 自动恢复时间间隔(秒)
	 */
	public int getCooldown() {
		return cooldown;
	}
	
	/**
	 * 恢复数量
	 */
	public int getRecoverCount() {
		return recoverCount;
	}
	
	/**
	 * 最大恢复上限
	 */
	public int getMaxRecoverCount() {
		return maxRecoverCount;
	}
	
	/**
	 * 购买价格 格式111:50:10|222:50:10&333:50:10-222:50:10&333:50:10
	 */
	public String[] getPrice() {
		return price;
	}
	
	/**
	 * 重置购买次数时间
	 */
	public int getResetBuyCountTime() {
		return resetBuyCountTime;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.itemId;
        values[2] = this.cooldown;
        values[3] = this.recoverCount;
        values[4] = this.maxRecoverCount;
        values[5] = this.price;
        values[6] = this.resetBuyCountTime;
        return values;
	}
	
	protected ItemRecoverCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.itemId = (int)vals[1];
		this.cooldown = (int)vals[2];
		this.recoverCount = (int)vals[3];
		this.maxRecoverCount = (int)vals[4];
		this.price = (String[])vals[5];
		this.resetBuyCountTime = (int)vals[6];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.itemId);
        map.put(keys[2], this.cooldown);
        map.put(keys[3], this.recoverCount);
        map.put(keys[4], this.maxRecoverCount);
        map.put(keys[5], this.price);
        map.put(keys[6], this.resetBuyCountTime);
        return map;
    }
    
    protected ItemRecoverCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.itemId = (int)map.get(keys[1]);
   		this.cooldown = (int)map.get(keys[2]);
   		this.recoverCount = (int)map.get(keys[3]);
   		this.maxRecoverCount = (int)map.get(keys[4]);
   		this.price = (String[])map.get(keys[5]);
   		this.resetBuyCountTime = (int)map.get(keys[6]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.itemId);
        obj.put(keys[2], this.cooldown);
        obj.put(keys[3], this.recoverCount);
        obj.put(keys[4], this.maxRecoverCount);
        obj.put(keys[5], this.price);
        obj.put(keys[6], this.resetBuyCountTime);
        return obj;
    }
    
    protected ItemRecoverCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.itemId = obj.getIntValue(keys[1]);
	    this.cooldown = obj.getIntValue(keys[2]);
	    this.recoverCount = obj.getIntValue(keys[3]);
	    this.maxRecoverCount = obj.getIntValue(keys[4]);
		this.price = obj.getObject(keys[5],String[].class);
	    this.resetBuyCountTime = obj.getIntValue(keys[6]);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeInt(this.itemId);
	    byteBuf.writeInt(this.cooldown);
	    byteBuf.writeInt(this.recoverCount);
	    byteBuf.writeInt(this.maxRecoverCount);
	    byteBuf.writeObject(this.price);
	    byteBuf.writeInt(this.resetBuyCountTime);
    }
	
	protected ItemRecoverCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.itemId = byteBuf.readInt(null);
	    this.cooldown = byteBuf.readInt(null);
	    this.recoverCount = byteBuf.readInt(null);
	    this.maxRecoverCount = byteBuf.readInt(null);
	    this.price = byteBuf.readStringArray(null);
	    this.resetBuyCountTime = byteBuf.readInt(null);
	    return this;
	}
	
	public ItemRecoverCfg deepCopy(){
		ItemRecoverCfg itemRecoverCfg = null;
		try {
			itemRecoverCfg = (ItemRecoverCfg) super.clone();
		    itemRecoverCfg.price = ToolCopy.copyObject(this.price);
			return itemRecoverCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return itemRecoverCfg;
	}
//自定义内容起始位置
	private List<List<Map<String, Object>>> priceMap = null;



	public List<List<Map<String, Object>>> getPriceMap() {
		return priceMap;
	}

	public void setPriceMap(List<List<Map<String, Object>>> priceMap) {
		this.priceMap = priceMap;
	}

	
//自定义内容结束位置
}
